package ipt.capitulo11;

public class SegundoHilo implements Runnable{
	
	static final short limiteS = 1000;
	private short limiteI =0;
		
	public void run(){
		while( limiteI++ < limiteS){
			System.out.print("El hilo actual es: ");
			System.out.println(	Thread.currentThread().toString() );
			try{
				Thread.currentThread().sleep(100);
			}catch(InterruptedException e){
				e.printStackTrace();
				System.out.print("InterruptedException "); 
				System.out.println("el hilo hijo");
			}
			System.exit(1);
		}
	}
	
	
	public static void main(String args[]){
		
		SegundoHilo destino = new SegundoHilo();
		Thread nuevoHilo=new Thread(destino,"Nuevo hilo");		
		nuevoHilo.start();
		Thread hiloAux = nuevoHilo;
		nuevoHilo=null;
		hiloAux.interrupt();
		System.out.print("El hilo principal ");
		System.out.println("ha terminado");
	}
	
}
